package Probleme;

import java.util.Vector;

import Objet.ListeObjets;
import Objet.Objet;

public class Generator {
	public int				nbinst;
	public int				op;
	public int				ow;
	public int				t;
	public Vector<Instance>	instances;

	public Generator(int nbinst, int t, int op, int ow) {
		this.op = op;
		this.t = t;
		this.ow = ow;
		this.nbinst = nbinst;
		this.instances = new Vector<Instance>();
		for (int i = 0; i < nbinst; i++) {
			this.instances.add(this.MakeInstance(t, op, ow));
		}
	}

	public void affiche() {
		for (int i = 0; i < this.nbinst; i++) {
			System.out.println("instance " + i + "\n");
			this.instances.get(i).affiche();
		}
	}

	public Instance MakeInstance(int taille, int ordrepoids, int ordreprofit) {
		Instance pb;
		int poids;
		int util;
		ListeObjets x;
		x = new ListeObjets();
		for (int i = 0; i < taille; i++) {
			poids = (int) (Math.random() * ordrepoids) + 1;
			
			util = (int) (Math.random() * ordreprofit) + 1;
			x.ajout(new Objet(i, poids, util));
		}
		poids = (int) (Math.random() * x.getpoids()) + 5;
		pb = new Instance(taille, x, poids, poids);
		return pb;
	}
}
